import Vue from 'vue'
import App from './App.vue'
import VueRouter from 'vue-router'

import  './assets/css/global.css'
//element引入
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
//路由引入
import  Router from './router'
import { Message } from 'element-ui'
// e-char
import * as echarts from 'echarts'
import axios from "axios";
//自定义表格工具扩展
import RightToolbar from "@/components/RightToolbar"
//安装
Vue.prototype.$echarts = echarts;



Vue.use(ElementUI)
Vue.prototype.$message= Message
//axios引入
Vue.prototype.$http =axios
axios.defaults.baseURL ='http://localhost:8888/'

Vue.config.productionTip = false

// 全局组件挂载
Vue.component('RightToolbar', RightToolbar)

Vue.use(VueRouter )

new Vue({

  render: h => h(App),
    router:Router
}).$mount('#app')


// 添加一个响应拦截器
axios.interceptors.response.use(function (response) {
  return response;
}, function (error) {
  console.log(error.response)
  // 401处理跳转登录页面 替换地址栏URL
  if (error.response.status == 401) {
    //没有token需要登录
    Message.error('未登录！');
    // window.location.href = "/login";
  }
  return Promise.reject(error);
})

